package elcs.mentoring.model;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.aspectj.weaver.ast.Not;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.stereotype.Repository;

import elcs.member.model.MemberVO;
@Repository
public class NoteDaoImpl implements NoteDao {
	@Resource(name="sqlSessionTemplate")
	private SqlSessionTemplate sqlSessionTemplate;
	/**
	 * 멘토 레벨 선택 시  자신의 레벨과 비교하여 
	 * 소모되는 포인트를 계산하여 보여준다.
	 * BY SSA
	 */
	@Override
	public int getPointForRequest(Map map) throws Exception {
		return this.sqlSessionTemplate.selectOne("mentoring.getPointForRequest", map);
	}
	/**
	 * 질문 버튼을 클릭하면 선택한 멘토에게 
	 * 질문이 전송되고, 해당되는 포인트가 감소된다.
	 * BY SSA
	 */
	@Override
	public int sendMentorQuestion(NoteVO nvo) throws Exception {
		return this.sqlSessionTemplate.insert("mentoring.sendMentorQuestion",nvo);
	}


	@Override
	public List getQuestionList(Map map) throws Exception {
		return this.sqlSessionTemplate.selectList("note.getQuestionList",map);
	}

	@Override
	public List findStatusList(NoteVO nvo) throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public NoteVO viewNoteContent(int no) throws Exception {
		return this.sqlSessionTemplate.selectOne("note.viewNoteContent",no);
	}

	@Override
	public void setReceiveDate(int no) throws Exception {
		this.sqlSessionTemplate.update("note.setReceiveDate",no);
	}

	@Override
	public int rejectMentorQuestion(int no) throws Exception {
		return this.sqlSessionTemplate.update("note.rejectMentorQuestion",no);
	}

	@Override
	public int replyMentorQuestion(NoteVO nvo) throws Exception {
		return this.sqlSessionTemplate.insert("mentoring.replyMentorQuestion", nvo);		
	}
	public void checkReplyQuestion(int no) throws Exception{
		this.sqlSessionTemplate.update("mentoring.checkReplyQuestion",no);
	}
	
	@Override
	public List getNoteList(Map map) throws Exception {
		return this.sqlSessionTemplate.selectList("mentoring.getNoteList",map);
	}
	@Override
	public int sendNote(NoteVO nvo) throws Exception {
		return this.sqlSessionTemplate.insert("mentoring.sendNote",nvo);
	}

	@Override
	public List findNoteList(NoteVO nvo) throws Exception {
		// TODO Auto-generated method stub
		return null;
	}


	@Override
	public int replyNote(NoteVO nvo) throws Exception {
		// TODO Auto-generated method stub
		return 0;
	}


	@Override
	public void sendOtherMentorQuestion(NoteVO nvo) {
	this.sqlSessionTemplate.insert("note.sendOtherMentorQuestion",nvo);

	}
	@Override
	public void receiverDeleteNote(int no) throws Exception {
		this.sqlSessionTemplate.update("note.receiverDeleteNote",no);
	}
	@Override
	public void senderDeleteNote(int no) throws Exception {
		this.sqlSessionTemplate.update("note.senderDeleteNote",no);
		
	}
	@Override
	public NoteVO getContent(int no) throws Exception {
		return this.sqlSessionTemplate.selectOne("note.getContent",no);
	}
	@Override
	public int getQuestionNumber(Map map) throws Exception {
		System.out.println(map);
		return this.sqlSessionTemplate.selectOne("note.getQuestionNumber",map);
	}


	public void updateReject(int no) throws Exception{
		this.sqlSessionTemplate.update("mentoring.updateReject",no);
	}
	@Override
	public int deleteNote(NoteVO nvo) throws Exception {
		// TODO Auto-generated method stub
		return 0;
	}
	@Override
	public void setReceiveDate(Map map) throws Exception {
		this.sqlSessionTemplate.update("note.setReceiveDateByMap",map);
	}
}




